package com.woniu.mapper;

import com.woniu.entity.Goods;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface GoodsMapper {

    @Insert("insert into goods (pid,pname,price,stock,uid,merchant_id) values (#{pid},#{pname},#{price},#{stock},#{uid},#{merchant_id})")
    public void insertGoods (Goods goods);

    @Select("select * from goods where pid=#{pid}")
    public Goods selectGoodsById (@Param("pid") Integer pid,@Param("uid")Integer uid);

    @Update("update goods set stock = stock + #{stock} where pid=#{pid} and uid=#{uid}")
    public void updateGoods(@Param("stock") Integer stock,@Param("pid") Integer pid,@Param("uid")Integer uid);

    @Select("select * from goods")
    public List<Goods> selectGoodsAll(Integer uid);

    @Delete("delete from goods where uid=#{uid}")
    public void deleteGoodsByUid(Integer uid);

    @Delete("delete from goods where uid=#{uid} and pid=#{pid}")
    public void deleteGoodsByPidUId(@Param("uid") Integer uid,@Param("pid") Integer pid);

    @Delete("delete from goods where merchant_id=#{merchant_id}")
    public void deleteGoodsByMerchantId(Integer merchant_id);
}
